Skip to content

Conversation

@baseballyama
Copy link
Member

close: #1433

Copilot AI review requested due to automatic review settings December 4, 2025 08:53
@changeset-bot
Copy link

changeset-bot bot commented Dec 4, 2025

🦋 Changeset detected

Latest commit: c3643d5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

Try the Instant Preview in Online Playground

ESLint Online Playground

Install the Instant Preview to Your Local

npm i https://pkg.pr.new/eslint-plugin-svelte@c3643d5

Published Instant Preview Packages:

View Commit

Copilot finished reviewing on behalf of baseballyama December 4, 2025 08:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the prefer-destructured-store-props ESLint rule to properly handle Svelte 5 runes. The rule was incorrectly flagging rune member expressions (like $state.raw, $derived.by, $effect.pre) as stores that should be destructured. The fix adds logic to skip these Svelte 5 runes when the runes mode is enabled.

Key changes:

  • Added SVELTE_RUNES set containing Svelte 5 rune identifiers that should be excluded from store destructuring checks
  • Added conditional check to skip rune member expressions when runes === true
  • Added test cases to verify runes are properly handled while actual stores are still caught

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/eslint-plugin-svelte/src/rules/prefer-destructured-store-props.ts Core fix: imports getSvelteContext, defines SVELTE_RUNES set, and adds check to skip rune member expressions when runes are enabled
packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-destructured-store-props/valid/runes01-input.svelte.js Valid test case showing Svelte 5 rune usage in a class
packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-destructured-store-props/valid/runes01-requirements.json Specifies Svelte 5+ requirement for the valid test
packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-destructured-store-props/invalid/runes-with-store01-input.svelte Invalid test case verifying stores are still flagged when runes are present
packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-destructured-store-props/invalid/runes-with-store01-requirements.json Specifies Svelte 5+ requirement for the invalid test
packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-destructured-store-props/invalid/runes-with-store01-errors.yaml Expected error and autofix suggestion for the invalid test case
.changeset/wet-kiwis-cover.md Changeset documenting the patch-level fix
Comments suppressed due to low confidence (1)

packages/eslint-plugin-svelte/src/rules/prefer-destructured-store-props.ts:26

  • The SVELTE_RUNES set is missing $restProps, which is a built-in reactive variable in Svelte 5 that should also be excluded from this rule. When $restProps is used (e.g., {$restProps.foo}), it shouldn't be flagged for destructuring as it's a Svelte-managed reactive object, not a user-defined store.

Add '$restProps' to the set.

			description:
				'destructure values from object stores for better change tracking & fewer redraws',
			category: 'Best Practices',
			recommended: false
		},
		hasSuggestions: true,
		schema: [],
		messages: {
			useDestructuring: `Destructure {{property}} from {{store}} for better change tracking & fewer redraws`,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ota-meshi ota-meshi merged commit a87e40b into main Dec 5, 2025
29 checks passed
@ota-meshi ota-meshi deleted the fix/prefer-destructured-store-props branch December 5, 2025 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

svelte/prefer-destructured-store-props doesn't like $derived.by in .svelte.ts files

3 participants